<?php

Class Region extends CI_Model {
    


    function get_list() {
        //$institute_id = $this->session->userdata('institute_id');
        
        $this->db->select('*');
        $this->db->from('region');
        
//        if ($this->input->post('search_type')) {
//            $search_type = $this->input->post('search_type');
//            $search = $this->input->post('search');
//            $this->db->like($search_type, $search);
//        }
        //$this->db->limit($this->config->item('number_of_rows'), $limit);
        //$this->db->order_by("id", "asc");
        $query = $this->db->get();

        if ($query->num_rows() >= 1) {
            return $query->result_array();
        } else {
            return false;
        }
    }

    function delete($id) {
        $this->db->delete('region', array('id' => $id));
        return "Đã xóa!";
        
    }

    function insert($newAttitudeCriteria) {
        if ($this->db->insert('region', $newAttitudeCriteria)) {
            return "Đã thêm!";
        } else {
            return "Unable to add";
        }
    }

    // get particular user detail
    function get($id) {
        $query = $this->db->get_where('region', array('id' => $id));
        return $query->row_array();
    }

   
    
    function update($attitudeCriteria)
    {
        $this->db->where('id', $attitudeCriteria['id']);
        $this->db->update('region', $attitudeCriteria);
        return "Đã cập nhật!";
    }

}

?>
